<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="~{fragment::head(title='首页')}">
</head>
<body>




<!--导航-->
<nav class="ui inverted attached segment" th:replace="~{fragment::nav(n=1)}">

</nav>



<!--中间的内容-->


    <div class="ui container">
        <div class="ui grid stackable">
            <!--        左边占九份-->
            <div class="eleven wide column">
<!--                header-->
                <div class="ui segment top attached">
                    <div class="ui two column grid">
                        <div class="column">
                            <div class="ui header teal">博客</div>
                        </div>
                        <div class="column right aligned ">
                            共<h3 class="ui header orange m-inline-block" th:text="${count}"></h3>篇博客
                        </div>
                    </div>
                </div>

                <div th:id="blog-content">
                    <th:block th:if="${jsonResult!=null}">
                        <!--content-->

                        <th:block th:fragment="blogs">
                            <div class="ui segment attached" >
                                <div class="ui padded vertical segment" th:each="blog : ${jsonResult.data.data}">
                                    <a th:href="@{/user/toBlog/{bid}(bid=${blog.id})}">
                                        <div class="ui grid mobile reversed stackable">
                                            <div class="eleven wide column">
                                                <h3 class="ui header" th:text="${blog.title}">这是标题</h3>
                                                <p th:text="${blog.flag}">这是段落篇</p>

                                                <div class="ui grid">
                                                    <div class="eleven wide column">
                                                        <div class="ui horizontal link list">
                                                            <div class="item">
                                                                <h4 class="ui teal inline header">
                                                                    <img th:src="@{/images/头像.png}" class="ui mini circular image">
                                                                    want
                                                                </h4>
                                                            </div>

                                                            <div class="item">
                                                                <i class="calendar icon"></i>
                                                                <span th:text="${#dates.format(blog.createDate,'yyyy-MM-dd')}">yyyy-MM-dd</span>
                                                            </div>
                                                            <div class="item">
                                                                <i class="eye icon"></i>
                                                                <span th:text="${blog.views}">33</span>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="right aligned five wide column">
                                                        <label class="ui teal basic label"><span th:text="${blog.type.name}"></span></label>
                                                    </div>
                                                </div>
                                            </div>

                                            <div class="right aligned five wide column">
                                                <img th:src="@{/images/海绵宝宝.png}" alt="ccc" class="ui image">
                                            </div>
                                        </div>
                                    </a>
                                </div>
                            </div>

                            <!--footer-->
                            <div class="ui segment bottom attached">
                                <div class="ui two column grid">
                                    <div class="column left aligned">
                                        <button class="ui teal button" th:attr="data-curr=${jsonResult.data.prePage}" onclick="pageH(this)">上一页</button>
                                    </div>
                                    <div class="column right aligned">
                                        <button class="ui teal button" th:attr="data-curr=${jsonResult.data.nextPage}" onclick="pageH(this)">下一页</button>
                                    </div>
                                </div>
                            </div>
                        </th:block>


                    </th:block>
                </div>





        </div>
            <!--        右边占五份-->
            <div class="five wide column">

<!--                分类-->
                <div class="ui segment">
                    <div class="ui secondary segment top attached">
                        <div class="ui two column grid">
                            <div class="column left aligned">
                                <i class="ui idea icon"></i>分类
                            </div>

                            <div class="right aligned column">
                                <a href="">more<i class="ui angle double icon"></i></a>
                            </div>
                        </div>
                    </div>

                    <div class="ui segment teal attached">
                        <div class="ui fluid vertical menu" th:each="type:${typeList}">
                            <a href="" class="item">
                                <span th:text="${type.name}"></span>
                                <label  class="ui teal basic left pointing label">11</label>
                            </a>
                        </div>
                    </div>
                </div>
<!--                标签-->
                <div class="ui segment">
                    <div class="ui secondary segment top attached">
                        <div class="ui two column grid">
                            <div class="column">
                                <i class="ui tag icon"></i>标签
                            </div>
                            <div class="column right aligned">
                                <a href="">more<i class="ui angle double icon"></i></a>
                            </div>
                        </div>
                    </div>

                    <div class="ui segment attached" th:each="tag : ${tagList}">
                        <a  class="ui teal basic left pointing label m-margin-tb"><span th:text="${tag.name}"></span></a>
                    </div>
                </div>


<!--                最新推荐-->

                <div class="ui segment">
                    <div class="ui secondary segment top attached">
                        <i class="ui bookmark icon"></i>
                        <span>最新推荐</span>
                    </div>

                    <div class="ui teal segment attached">
                        <div class="ui fluid vertical menu">
                            <a class="item" href="#"><span>用户故事</span></a>
                            <a class="item" href="#"><span>用户故事</span></a>
                            <a class="item" href="#"><span>用户故事</span></a>
                        </div>
                    </div>
                </div>
            </div>
    </div>

</div>


<!--底部的内容-->

<footer class="ui inverted vertical segment" th:replace="~{fragment::footer}">
</footer>

<th:block th:replace="~{fragment :: script}">
</th:block>

<script type="text/javascript">

    $(function () {
        $.ajax({
            url:"/user/listBlog",
            type:"get",
            success:function (res) {
                $('#blog-content').html(res);
                console.log(res)
            }
        })
    })

    // $('.m-mobile-show.m-right-top').click(function () {
    //     $('.m-item').toggleClass('m-mobile-hide');
    // });

    //分页函数
    function pageH(curr) {
        var currpage=$(curr).data("curr");
        $.ajax({
            url:"/user/listBlog",
            type: "get",
            data:{
                "currentPage":currpage,
            },
            success:function (res) {
                $('#blog-content').html(res);
            }
        })
    }
</script>
</body>
</html>